/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ondrej
 */
@Entity
@Table(name = "contact")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Contact.findAll", query = "SELECT c FROM Contact c"),
    @NamedQuery(name = "Contact.findById", query = "SELECT c FROM Contact c WHERE c.id = :id"),
    @NamedQuery(name = "Contact.findByTitle", query = "SELECT c FROM Contact c WHERE c.title = :title"),
    @NamedQuery(name = "Contact.findByWebpage", query = "SELECT c FROM Contact c WHERE c.webpage = :webpage"),
    @NamedQuery(name = "Contact.findByDescription", query = "SELECT c FROM Contact c WHERE c.description = :description"),
    @NamedQuery(name = "Contact.findByActiveFrom", query = "SELECT c FROM Contact c WHERE c.activeFrom = :activeFrom"),
    @NamedQuery(name = "Contact.findByActiveTo", query = "SELECT c FROM Contact c WHERE c.activeTo = :activeTo")})
public class Contact implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Size(max = 40)
    @Column(name = "title")
    private String title;
    @Size(max = 20)
    @Column(name = "webpage")
    private String webpage;
    @Size(max = 400)
    @Column(name = "description")
    private String description;
    @Column(name = "active_from")
    private Integer activeFrom;
    @Column(name = "active_to")
    private Integer activeTo;
    @JoinColumn(name = "PERSON_id", referencedColumnName = "id")
    @ManyToOne
    private Person pERSONid;
    @JoinColumn(name = "CONTACT_TYPE_id", referencedColumnName = "id")
    @ManyToOne
    private ContactType cONTACTTYPEid;
    @OneToMany(mappedBy = "cONTACTid")
    private Collection<ContactProject> contactProjectCollection;

    public Contact() {
    }

    public Contact(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getWebpage() {
        return webpage;
    }

    public void setWebpage(String webpage) {
        this.webpage = webpage;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getActiveFrom() {
        return activeFrom;
    }

    public void setActiveFrom(Integer activeFrom) {
        this.activeFrom = activeFrom;
    }

    public Integer getActiveTo() {
        return activeTo;
    }

    public void setActiveTo(Integer activeTo) {
        this.activeTo = activeTo;
    }

    public Person getPERSONid() {
        return pERSONid;
    }

    public void setPERSONid(Person pERSONid) {
        this.pERSONid = pERSONid;
    }

    public ContactType getCONTACTTYPEid() {
        return cONTACTTYPEid;
    }

    public void setCONTACTTYPEid(ContactType cONTACTTYPEid) {
        this.cONTACTTYPEid = cONTACTTYPEid;
    }

    @XmlTransient
    public Collection<ContactProject> getContactProjectCollection() {
        return contactProjectCollection;
    }

    public void setContactProjectCollection(Collection<ContactProject> contactProjectCollection) {
        this.contactProjectCollection = contactProjectCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Contact)) {
            return false;
        }
        Contact other = (Contact) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entities.Contact[ id=" + id + " ]";
    }
    
}
